<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>分支结构</title>
    <script type="text/javascript">
        let married;

        if (married) {
            console.log('已婚');
        } else {
            console.log('未婚');
        }

        married = true;
        if (married) {
            console.log('已婚');
        }

        // 随机产生 [ 0 , 1 ) 之间的浮点数
        let r = Math.random();
        console.log(r);

        // 产生 [ 0 , 100 ) 之间的浮点数
        let s = r * 100;
        console.log(s);

        // 通过 将 浮点数 与 零 按位或 将浮点数转换为整数
        let score = s | 0;
        console.log(score);

        if (score > 100) {
            console.log('成绩超出最高范围');
        } else if (score >= 90) {
            console.log('优');
        } else if (score >= 80) {
            console.log('良');
        } else if (score >= 70) {
            console.log('常');
        } else if (score >= 60) {
            console.log('可');
        } else if (score >= 0) {
            console.log('劣');
        } else {
            console.log('成绩超出最低范围');
        }
    </script>
</head>

<body>

    若 married 取值为以下之一:
    <ul>
        <li>undefined</li>
        <li>null</li>
        <li>空字符串</li>
        <li>NaN</li>
        <li>0</li>
        <li>false (注意它不是字符串而是boolean类型直接量)</li>
    </ul>
    则都认为 married 为 false

</body>

</html>